package com.leolian.spring01.resource;

import java.io.IOException;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.io.Resource;


public class SpringResource implements ApplicationContextAware{
	private ApplicationContext ctx;

	public void setApplicationContext(ApplicationContext ctx)
			throws BeansException {
		this.ctx = ctx;
	}
	
	public void resource() throws IOException{
		//Resource rs = ctx.getResource("classpath:config.txt");
		//Resource rs = ctx.getResource("file:E:\\temp_code\\config.txt");
		Resource rs = ctx.getResource("url:http://news.zhibo8.cc/nba/");
		System.out.println(rs.getFilename());
		System.out.println(rs.contentLength());
	}
}
